package main.Q2101_2200;

import java.util.ArrayList;
import java.util.List;

public class Q2121_2130 {
    public static void main(String[] args) {
        System.out.println("Question2121：");
        System.out.println("Question2122：");
        System.out.println("Question2123：");
        System.out.println("Question2124：");
        System.out.println("Question2125：银行中的激光束数量");
        System.out.println("Question2126：");
        System.out.println("Question2127：");
        System.out.println("Question2128：");
        System.out.println("Question2129：");
        System.out.println("Question2130：链表最大孪生和");
    }
}

class ListNode {
    int val;
    ListNode next;

    ListNode() {
    }

    ListNode(int val) {
        this.val = val;
    }

    ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
}

class Question2125 {
    public int process(String str) {
        int count = 0;
        for (char c : str.toCharArray()) {
            if (c == '1') count++;
        }
        return count;
    }

    public int numberOfBeams(String[] bank) {
        int result = 0;
        int lastCount = process(bank[0]), cur = 0;
        for (int i = 1; i < bank.length; i++) {
            cur = process(bank[i]);
            if (cur == 0) continue;
            result += cur * lastCount;
            lastCount = cur;
            cur = 0;
        }
        return result;
    }
}

class Question2130 {
    public int pairSum(ListNode head) {
        List<Integer> list = new ArrayList<>();
        while (head != null) {
            list.add(head.val);
            head = head.next;
        }
        int max = 0;
        for (int i = 0; i < list.size() / 2; i++) {
            int temp = list.get(i) + list.get(list.size() - 1 - i);
            max = Math.max(max, temp);
        }
        return max;
    }
}